
#include "gmatlab.h"

// void g_irepository_matlab_load_pkg(const gchar *name);
void mexFunction(int nlhs, mxArray *lhs[], int nrhs, const mxArray *rhs[])
{
  GError *err = NULL;
  gchar *name;

  // Check and convert arguments
  if (nrhs != 1) g_matlab_error("gmatlab:numArg", "g_irepository_matlab_load_pkg() takes 1 argument");
  if (nlhs != 0) g_matlab_error("gmatlab:numRet", "g_irepository_matlab_load_pkg() has 0 return values");
  if (mxGetClassID(rhs[0]) != mxCHAR_CLASS) g_matlab_error("gmatlab:badType", "g_irepository_matlab_load_pkg() Arg 1 must be char, not %s", mxGetClassName(rhs[0]));
  name = g_matlab_mxArray_get_utf8(rhs[0]);
  g_matlab_cleanup_add(g_free, name);
  
  // Call function
  if (g_irepository_require(NULL, name, NULL, 0, &err) == NULL)
    g_matlab_error_with_error("gmatlab:loadError", err, "Error loading GObject-Introspection package %s", name);
  
  // Prepare return value
}
